// 系统菜单配置
export const menuConfig = [
  {
    id: 1,
    name: "AGV管理",
    icon: "car",
    children: [
      {
        id: 11,
        name: "AGV位置监控",
        path: "/AGV/AGV_position",
        icon: "map-marker"
      },
      {
        id: 12,
        name: "AGV配置列表",
        path: "/AGV/Config_list",
        icon: "list"
      },
      {
        id: 13,
        name: "添加AGV配置",
        path: "/AGV/Config_add",
        icon: "plus-circle"
      },
      {
        id: 14,
        name: "添加虚拟AGV",
        path: "/AGV/simulation_list",
        icon: "robot"
      },
      {
        id: 15,
        name: "站点管理",
        path: "/AGV/Station_list",
        icon: "building"
      }
    ]
  },
  {
    id: 2,
    name: "任务管理",
    icon: "task",
    children: [
      {
        id: 21,
        name: "任务列表",
        path: "/Task/Task_list",
        icon: "list"
      }
    ]
  }
];

// 获取用户菜单（这里简化处理，实际项目中应该根据用户角色权限返回不同的菜单）
export const getUserMenus = () => {
  // 实际项目中这里应该从后端获取用户有权限的菜单
  return menuConfig;
};

// 根据路径获取菜单标题
export const getMenuTitleByPath = (path) => {
  let title = '';
  const findTitle = (menus) => {
    for (const menu of menus) {
      if (menu.path === path) {
        title = menu.name;
        return true;
      }
      if (menu.children && menu.children.length > 0) {
        if (findTitle(menu.children)) {
          return true;
        }
      }
    }
    return false;
  };
  findTitle(menuConfig);
  return title;
};
